/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colloque.helpers;

import colloque.HibernateUtil;
import colloque.Institution;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author Thomas
 */
public class InstitutionHelper {

     Session session = null;
    
    /**
     *
     */
    public InstitutionHelper() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }
    
    
    /**
     * Retourne toutes les institutions
     * 
     * @return
     */
    public List<Institution> getallinstitution(){
        List<Institution> Tabins = new ArrayList<Institution>();

        try {
            Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Institution as Instit ");
            Tabins = q.list();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        
        return Tabins;
        
    }
    
    
    
}
